#include "swbox.h"

#include "db.h"
using namespace db;

/***** SwitchBox *****/

#define SWITCHBOX_CONNECT_MAX_DISTANCE 6

SwitchBox::SwitchBox() {
    x = -1;
    y = -1;
    connections.resize(SWITCHBOX_CONNECT_MAX_DISTANCE * 4, NULL);
    supply.resize(SWITCHBOX_CONNECT_MAX_DISTANCE * 4, 0);
    demand.resize(SWITCHBOX_CONNECT_MAX_DISTANCE * 4, 0);
}

SwitchBox::SwitchBox(int x, int y) {
    this->x = x;
    this->y = y;
    this->connections.resize(SWITCHBOX_CONNECT_MAX_DISTANCE * 4, NULL);
    this->supply.resize(SWITCHBOX_CONNECT_MAX_DISTANCE * 4, 0);
    this->demand.resize(SWITCHBOX_CONNECT_MAX_DISTANCE * 4, 0);
}

SwitchBox::SwitchBox(const SwitchBox &switchbox) {
    x = switchbox.x;
    y = switchbox.y;
    sites = switchbox.sites;
    connections = switchbox.connections;
    supply = switchbox.supply;
    demand = switchbox.demand;
}

bool SwitchBox::getSwitchBoxOffset(int i, int &x, int &y) {
    x = y = 0;
    if (i < 0 || i >= SWITCHBOX_CONNECT_MAX_DISTANCE * 4) {
        return false;
    }
    int direction = i % 4;
    int distance = i / 4;
    if (direction == 0) {
        y = distance + 1;
    } else if (direction == 1) {
        x = distance + 1;
    } else if (direction == 2) {
        y = -distance - 1;
    } else {
        x = -distance - 1;
    }
    return true;
}

/***** Pin Mapping *****/

void Database::setPinMap() {
    unordered_map<string, int> DSP0PinMap;
    unordered_map<string, int> DSP1PinMap;
    unordered_map<string, int> BRAMPinMap;

    // DSP0
    DSP0PinMap["CARRYCASCIN"] = -1;
    DSP0PinMap["CARRYIN"] = 2;
    DSP0PinMap["CEA1"] = 0;
    DSP0PinMap["CEA2"] = 0;
    DSP0PinMap["CEAD"] = 1;
    DSP0PinMap["CEALUMODE"] = 0;
    DSP0PinMap["CEB1"] = 1;
    DSP0PinMap["CEB2"] = 0;
    DSP0PinMap["CEC"] = 0;
    DSP0PinMap["CECARRYIN"] = 2;
    DSP0PinMap["CECTRL"] = 2;
    DSP0PinMap["CED"] = 1;
    DSP0PinMap["CEINMODE"] = 0;
    DSP0PinMap["CEM"] = 1;
    DSP0PinMap["CEP"] = 2;
    DSP0PinMap["CLK"] = 1;
    DSP0PinMap["MULTSIGNIN"] = -1;
    DSP0PinMap["RSTA"] = 0;
    DSP0PinMap["RSTALLCARRYIN"] = 2;
    DSP0PinMap["RSTALUMODE"] = 0;
    DSP0PinMap["RSTB"] = 1;
    DSP0PinMap["RSTC"] = 0;
    DSP0PinMap["RSTCTRL"] = 2;
    DSP0PinMap["RSTD"] = 1;
    DSP0PinMap["RSTINMODE"] = 0;
    DSP0PinMap["RSTM"] = 1;
    DSP0PinMap["RSTP"] = 2;
    DSP0PinMap["A[29]"] = 3;
    DSP0PinMap["A[28]"] = 3;
    DSP0PinMap["A[27]"] = 3;
    DSP0PinMap["A[26]"] = 3;
    DSP0PinMap["A[25]"] = 3;
    DSP0PinMap["A[24]"] = 3;
    DSP0PinMap["A[23]"] = 2;
    DSP0PinMap["A[22]"] = 2;
    DSP0PinMap["A[21]"] = 2;
    DSP0PinMap["A[20]"] = 2;
    DSP0PinMap["A[19]"] = 2;
    DSP0PinMap["A[18]"] = 2;
    DSP0PinMap["A[17]"] = 2;
    DSP0PinMap["A[16]"] = 2;
    DSP0PinMap["A[15]"] = 1;
    DSP0PinMap["A[14]"] = 1;
    DSP0PinMap["A[13]"] = 1;
    DSP0PinMap["A[12]"] = 1;
    DSP0PinMap["A[11]"] = 1;
    DSP0PinMap["A[10]"] = 1;
    DSP0PinMap["A[9]"] = 1;
    DSP0PinMap["A[8]"] = 1;
    DSP0PinMap["A[7]"] = 0;
    DSP0PinMap["A[6]"] = 0;
    DSP0PinMap["A[5]"] = 0;
    DSP0PinMap["A[4]"] = 0;
    DSP0PinMap["A[3]"] = 0;
    DSP0PinMap["A[2]"] = 0;
    DSP0PinMap["A[1]"] = 0;
    DSP0PinMap["A[0]"] = 0;
    DSP0PinMap["ACIN[29]"] = -1;
    DSP0PinMap["ACIN[28]"] = -1;
    DSP0PinMap["ACIN[27]"] = -1;
    DSP0PinMap["ACIN[26]"] = -1;
    DSP0PinMap["ACIN[25]"] = -1;
    DSP0PinMap["ACIN[24]"] = -1;
    DSP0PinMap["ACIN[23]"] = -1;
    DSP0PinMap["ACIN[22]"] = -1;
    DSP0PinMap["ACIN[21]"] = -1;
    DSP0PinMap["ACIN[20]"] = -1;
    DSP0PinMap["ACIN[19]"] = -1;
    DSP0PinMap["ACIN[18]"] = -1;
    DSP0PinMap["ACIN[17]"] = -1;
    DSP0PinMap["ACIN[16]"] = -1;
    DSP0PinMap["ACIN[15]"] = -1;
    DSP0PinMap["ACIN[14]"] = -1;
    DSP0PinMap["ACIN[13]"] = -1;
    DSP0PinMap["ACIN[12]"] = -1;
    DSP0PinMap["ACIN[11]"] = -1;
    DSP0PinMap["ACIN[10]"] = -1;
    DSP0PinMap["ACIN[9]"] = -1;
    DSP0PinMap["ACIN[8]"] = -1;
    DSP0PinMap["ACIN[7]"] = -1;
    DSP0PinMap["ACIN[6]"] = -1;
    DSP0PinMap["ACIN[5]"] = -1;
    DSP0PinMap["ACIN[4]"] = -1;
    DSP0PinMap["ACIN[3]"] = -1;
    DSP0PinMap["ACIN[2]"] = -1;
    DSP0PinMap["ACIN[1]"] = -1;
    DSP0PinMap["ACIN[0]"] = -1;
    DSP0PinMap["B[17]"] = 2;
    DSP0PinMap["B[16]"] = 2;
    DSP0PinMap["B[15]"] = 1;
    DSP0PinMap["B[14]"] = 1;
    DSP0PinMap["B[13]"] = 1;
    DSP0PinMap["B[12]"] = 1;
    DSP0PinMap["B[11]"] = 1;
    DSP0PinMap["B[10]"] = 1;
    DSP0PinMap["B[9]"] = 1;
    DSP0PinMap["B[8]"] = 1;
    DSP0PinMap["B[7]"] = 0;
    DSP0PinMap["B[6]"] = 0;
    DSP0PinMap["B[5]"] = 0;
    DSP0PinMap["B[4]"] = 0;
    DSP0PinMap["B[3]"] = 0;
    DSP0PinMap["B[2]"] = 0;
    DSP0PinMap["B[1]"] = 0;
    DSP0PinMap["B[0]"] = 0;
    DSP0PinMap["BCIN[17]"] = -1;
    DSP0PinMap["BCIN[16]"] = -1;
    DSP0PinMap["BCIN[15]"] = -1;
    DSP0PinMap["BCIN[14]"] = -1;
    DSP0PinMap["BCIN[13]"] = -1;
    DSP0PinMap["BCIN[12]"] = -1;
    DSP0PinMap["BCIN[11]"] = -1;
    DSP0PinMap["BCIN[10]"] = -1;
    DSP0PinMap["BCIN[9]"] = -1;
    DSP0PinMap["BCIN[8]"] = -1;
    DSP0PinMap["BCIN[7]"] = -1;
    DSP0PinMap["BCIN[6]"] = -1;
    DSP0PinMap["BCIN[5]"] = -1;
    DSP0PinMap["BCIN[4]"] = -1;
    DSP0PinMap["BCIN[3]"] = -1;
    DSP0PinMap["BCIN[2]"] = -1;
    DSP0PinMap["BCIN[1]"] = -1;
    DSP0PinMap["BCIN[0]"] = -1;
    DSP0PinMap["D[26]"] = 3;
    DSP0PinMap["D[25]"] = 3;
    DSP0PinMap["D[24]"] = 3;
    DSP0PinMap["D[23]"] = 2;
    DSP0PinMap["D[22]"] = 2;
    DSP0PinMap["D[21]"] = 2;
    DSP0PinMap["D[20]"] = 2;
    DSP0PinMap["D[19]"] = 2;
    DSP0PinMap["D[18]"] = 2;
    DSP0PinMap["D[17]"] = 2;
    DSP0PinMap["D[16]"] = 2;
    DSP0PinMap["D[15]"] = 1;
    DSP0PinMap["D[14]"] = 1;
    DSP0PinMap["D[13]"] = 1;
    DSP0PinMap["D[12]"] = 1;
    DSP0PinMap["D[11]"] = 1;
    DSP0PinMap["D[10]"] = 1;
    DSP0PinMap["D[9]"] = 1;
    DSP0PinMap["D[8]"] = 1;
    DSP0PinMap["D[7]"] = 0;
    DSP0PinMap["D[6]"] = 0;
    DSP0PinMap["D[5]"] = 0;
    DSP0PinMap["D[4]"] = 0;
    DSP0PinMap["D[3]"] = 0;
    DSP0PinMap["D[2]"] = 0;
    DSP0PinMap["D[1]"] = 0;
    DSP0PinMap["D[0]"] = 0;
    DSP0PinMap["CARRYINSEL[2]"] = 0;
    DSP0PinMap["CARRYINSEL[1]"] = 0;
    DSP0PinMap["CARRYINSEL[0]"] = 0;
    DSP0PinMap["ALUMODE[3]"] = 0;
    DSP0PinMap["ALUMODE[2]"] = 0;
    DSP0PinMap["ALUMODE[1]"] = 0;
    DSP0PinMap["ALUMODE[0]"] = 0;
    DSP0PinMap["C[47]"] = 1;
    DSP0PinMap["C[46]"] = 1;
    DSP0PinMap["C[45]"] = 1;
    DSP0PinMap["C[44]"] = 1;
    DSP0PinMap["C[43]"] = 0;
    DSP0PinMap["C[42]"] = 0;
    DSP0PinMap["C[41]"] = 0;
    DSP0PinMap["C[40]"] = 0;
    DSP0PinMap["C[39]"] = 4;
    DSP0PinMap["C[38]"] = 4;
    DSP0PinMap["C[37]"] = 4;
    DSP0PinMap["C[36]"] = 4;
    DSP0PinMap["C[35]"] = 4;
    DSP0PinMap["C[34]"] = 4;
    DSP0PinMap["C[33]"] = 4;
    DSP0PinMap["C[32]"] = 4;
    DSP0PinMap["C[31]"] = 3;
    DSP0PinMap["C[30]"] = 3;
    DSP0PinMap["C[29]"] = 3;
    DSP0PinMap["C[28]"] = 3;
    DSP0PinMap["C[27]"] = 3;
    DSP0PinMap["C[26]"] = 3;
    DSP0PinMap["C[25]"] = 3;
    DSP0PinMap["C[24]"] = 3;
    DSP0PinMap["C[23]"] = 2;
    DSP0PinMap["C[22]"] = 2;
    DSP0PinMap["C[21]"] = 2;
    DSP0PinMap["C[20]"] = 2;
    DSP0PinMap["C[19]"] = 2;
    DSP0PinMap["C[18]"] = 2;
    DSP0PinMap["C[17]"] = 2;
    DSP0PinMap["C[16]"] = 2;
    DSP0PinMap["C[15]"] = 1;
    DSP0PinMap["C[14]"] = 1;
    DSP0PinMap["C[13]"] = 1;
    DSP0PinMap["C[12]"] = 1;
    DSP0PinMap["C[11]"] = 1;
    DSP0PinMap["C[10]"] = 1;
    DSP0PinMap["C[9]"] = 1;
    DSP0PinMap["C[8]"] = 1;
    DSP0PinMap["C[7]"] = 0;
    DSP0PinMap["C[6]"] = 0;
    DSP0PinMap["C[5]"] = 0;
    DSP0PinMap["C[4]"] = 0;
    DSP0PinMap["C[3]"] = 0;
    DSP0PinMap["C[2]"] = 0;
    DSP0PinMap["C[1]"] = 0;
    DSP0PinMap["C[0]"] = 0;
    DSP0PinMap["PCIN[47]"] = -1;
    DSP0PinMap["PCIN[46]"] = -1;
    DSP0PinMap["PCIN[45]"] = -1;
    DSP0PinMap["PCIN[44]"] = -1;
    DSP0PinMap["PCIN[43]"] = -1;
    DSP0PinMap["PCIN[42]"] = -1;
    DSP0PinMap["PCIN[41]"] = -1;
    DSP0PinMap["PCIN[40]"] = -1;
    DSP0PinMap["PCIN[39]"] = -1;
    DSP0PinMap["PCIN[38]"] = -1;
    DSP0PinMap["PCIN[37]"] = -1;
    DSP0PinMap["PCIN[36]"] = -1;
    DSP0PinMap["PCIN[35]"] = -1;
    DSP0PinMap["PCIN[34]"] = -1;
    DSP0PinMap["PCIN[33]"] = -1;
    DSP0PinMap["PCIN[32]"] = -1;
    DSP0PinMap["PCIN[31]"] = -1;
    DSP0PinMap["PCIN[30]"] = -1;
    DSP0PinMap["PCIN[29]"] = -1;
    DSP0PinMap["PCIN[28]"] = -1;
    DSP0PinMap["PCIN[27]"] = -1;
    DSP0PinMap["PCIN[26]"] = -1;
    DSP0PinMap["PCIN[25]"] = -1;
    DSP0PinMap["PCIN[24]"] = -1;
    DSP0PinMap["PCIN[23]"] = -1;
    DSP0PinMap["PCIN[22]"] = -1;
    DSP0PinMap["PCIN[21]"] = -1;
    DSP0PinMap["PCIN[20]"] = -1;
    DSP0PinMap["PCIN[19]"] = -1;
    DSP0PinMap["PCIN[18]"] = -1;
    DSP0PinMap["PCIN[17]"] = -1;
    DSP0PinMap["PCIN[16]"] = -1;
    DSP0PinMap["PCIN[15]"] = -1;
    DSP0PinMap["PCIN[14]"] = -1;
    DSP0PinMap["PCIN[13]"] = -1;
    DSP0PinMap["PCIN[12]"] = -1;
    DSP0PinMap["PCIN[11]"] = -1;
    DSP0PinMap["PCIN[10]"] = -1;
    DSP0PinMap["PCIN[9]"] = -1;
    DSP0PinMap["PCIN[8]"] = -1;
    DSP0PinMap["PCIN[7]"] = -1;
    DSP0PinMap["PCIN[6]"] = -1;
    DSP0PinMap["PCIN[5]"] = -1;
    DSP0PinMap["PCIN[4]"] = -1;
    DSP0PinMap["PCIN[3]"] = -1;
    DSP0PinMap["PCIN[2]"] = -1;
    DSP0PinMap["PCIN[1]"] = -1;
    DSP0PinMap["PCIN[0]"] = -1;
    DSP0PinMap["INMODE[4]"] = 2;
    DSP0PinMap["INMODE[3]"] = 0;
    DSP0PinMap["INMODE[2]"] = 1;
    DSP0PinMap["INMODE[1]"] = 1;
    DSP0PinMap["INMODE[0]"] = 0;
    DSP0PinMap["OPMODE[8]"] = 2;
    DSP0PinMap["OPMODE[7]"] = 1;
    DSP0PinMap["OPMODE[6]"] = 1;
    DSP0PinMap["OPMODE[5]"] = 1;
    DSP0PinMap["OPMODE[4]"] = 1;
    DSP0PinMap["OPMODE[3]"] = 0;
    DSP0PinMap["OPMODE[2]"] = 0;
    DSP0PinMap["OPMODE[1]"] = 0;
    DSP0PinMap["OPMODE[0]"] = 0;
    DSP0PinMap["CARRYCASCOUT"] = -1;
    DSP0PinMap["MULTSIGNOUT"] = -1;
    DSP0PinMap["OVERFLOW"] = 1;
    DSP0PinMap["PATTERNBDETECT"] = 0;
    DSP0PinMap["PATTERNDETECT"] = 0;
    DSP0PinMap["UNDERFLOW"] = 0;
    DSP0PinMap["BCOUT[17]"] = -1;
    DSP0PinMap["BCOUT[16]"] = -1;
    DSP0PinMap["BCOUT[15]"] = -1;
    DSP0PinMap["BCOUT[14]"] = -1;
    DSP0PinMap["BCOUT[13]"] = -1;
    DSP0PinMap["BCOUT[12]"] = -1;
    DSP0PinMap["BCOUT[11]"] = -1;
    DSP0PinMap["BCOUT[10]"] = -1;
    DSP0PinMap["BCOUT[9]"] = -1;
    DSP0PinMap["BCOUT[8]"] = -1;
    DSP0PinMap["BCOUT[7]"] = -1;
    DSP0PinMap["BCOUT[6]"] = -1;
    DSP0PinMap["BCOUT[5]"] = -1;
    DSP0PinMap["BCOUT[4]"] = -1;
    DSP0PinMap["BCOUT[3]"] = -1;
    DSP0PinMap["BCOUT[2]"] = -1;
    DSP0PinMap["BCOUT[1]"] = -1;
    DSP0PinMap["BCOUT[0]"] = -1;
    DSP0PinMap["ACOUT[29]"] = -1;
    DSP0PinMap["ACOUT[28]"] = -1;
    DSP0PinMap["ACOUT[27]"] = -1;
    DSP0PinMap["ACOUT[26]"] = -1;
    DSP0PinMap["ACOUT[25]"] = -1;
    DSP0PinMap["ACOUT[24]"] = -1;
    DSP0PinMap["ACOUT[23]"] = -1;
    DSP0PinMap["ACOUT[22]"] = -1;
    DSP0PinMap["ACOUT[21]"] = -1;
    DSP0PinMap["ACOUT[20]"] = -1;
    DSP0PinMap["ACOUT[19]"] = -1;
    DSP0PinMap["ACOUT[18]"] = -1;
    DSP0PinMap["ACOUT[17]"] = -1;
    DSP0PinMap["ACOUT[16]"] = -1;
    DSP0PinMap["ACOUT[15]"] = -1;
    DSP0PinMap["ACOUT[14]"] = -1;
    DSP0PinMap["ACOUT[13]"] = -1;
    DSP0PinMap["ACOUT[12]"] = -1;
    DSP0PinMap["ACOUT[11]"] = -1;
    DSP0PinMap["ACOUT[10]"] = -1;
    DSP0PinMap["ACOUT[9]"] = -1;
    DSP0PinMap["ACOUT[8]"] = -1;
    DSP0PinMap["ACOUT[7]"] = -1;
    DSP0PinMap["ACOUT[6]"] = -1;
    DSP0PinMap["ACOUT[5]"] = -1;
    DSP0PinMap["ACOUT[4]"] = -1;
    DSP0PinMap["ACOUT[3]"] = -1;
    DSP0PinMap["ACOUT[2]"] = -1;
    DSP0PinMap["ACOUT[1]"] = -1;
    DSP0PinMap["ACOUT[0]"] = -1;
    DSP0PinMap["CARRYOUT[3]"] = 2;
    DSP0PinMap["CARRYOUT[2]"] = 4;
    DSP0PinMap["CARRYOUT[1]"] = 3;
    DSP0PinMap["CARRYOUT[0]"] = 1;
    DSP0PinMap["P[47]"] = 1;
    DSP0PinMap["P[46]"] = 1;
    DSP0PinMap["P[45]"] = 1;
    DSP0PinMap["P[44]"] = 1;
    DSP0PinMap["P[43]"] = 0;
    DSP0PinMap["P[42]"] = 0;
    DSP0PinMap["P[41]"] = 0;
    DSP0PinMap["P[40]"] = 0;
    DSP0PinMap["P[39]"] = 4;
    DSP0PinMap["P[38]"] = 4;
    DSP0PinMap["P[37]"] = 4;
    DSP0PinMap["P[36]"] = 4;
    DSP0PinMap["P[35]"] = 4;
    DSP0PinMap["P[34]"] = 4;
    DSP0PinMap["P[33]"] = 4;
    DSP0PinMap["P[32]"] = 4;
    DSP0PinMap["P[31]"] = 3;
    DSP0PinMap["P[30]"] = 3;
    DSP0PinMap["P[29]"] = 3;
    DSP0PinMap["P[28]"] = 3;
    DSP0PinMap["P[27]"] = 3;
    DSP0PinMap["P[26]"] = 3;
    DSP0PinMap["P[25]"] = 3;
    DSP0PinMap["P[24]"] = 3;
    DSP0PinMap["P[23]"] = 2;
    DSP0PinMap["P[22]"] = 2;
    DSP0PinMap["P[21]"] = 2;
    DSP0PinMap["P[20]"] = 2;
    DSP0PinMap["P[19]"] = 2;
    DSP0PinMap["P[18]"] = 2;
    DSP0PinMap["P[17]"] = 2;
    DSP0PinMap["P[16]"] = 2;
    DSP0PinMap["P[15]"] = 1;
    DSP0PinMap["P[14]"] = 1;
    DSP0PinMap["P[13]"] = 1;
    DSP0PinMap["P[12]"] = 1;
    DSP0PinMap["P[11]"] = 1;
    DSP0PinMap["P[10]"] = 1;
    DSP0PinMap["P[9]"] = 1;
    DSP0PinMap["P[8]"] = 1;
    DSP0PinMap["P[7]"] = 0;
    DSP0PinMap["P[6]"] = 0;
    DSP0PinMap["P[5]"] = 0;
    DSP0PinMap["P[4]"] = 0;
    DSP0PinMap["P[3]"] = 0;
    DSP0PinMap["P[2]"] = 0;
    DSP0PinMap["P[1]"] = 0;
    DSP0PinMap["P[0]"] = 0;
    DSP0PinMap["PCOUT[47]"] = -1;
    DSP0PinMap["PCOUT[46]"] = -1;
    DSP0PinMap["PCOUT[45]"] = -1;
    DSP0PinMap["PCOUT[44]"] = -1;
    DSP0PinMap["PCOUT[43]"] = -1;
    DSP0PinMap["PCOUT[42]"] = -1;
    DSP0PinMap["PCOUT[41]"] = -1;
    DSP0PinMap["PCOUT[40]"] = -1;
    DSP0PinMap["PCOUT[39]"] = -1;
    DSP0PinMap["PCOUT[38]"] = -1;
    DSP0PinMap["PCOUT[37]"] = -1;
    DSP0PinMap["PCOUT[36]"] = -1;
    DSP0PinMap["PCOUT[35]"] = -1;
    DSP0PinMap["PCOUT[34]"] = -1;
    DSP0PinMap["PCOUT[33]"] = -1;
    DSP0PinMap["PCOUT[32]"] = -1;
    DSP0PinMap["PCOUT[31]"] = -1;
    DSP0PinMap["PCOUT[30]"] = -1;
    DSP0PinMap["PCOUT[29]"] = -1;
    DSP0PinMap["PCOUT[28]"] = -1;
    DSP0PinMap["PCOUT[27]"] = -1;
    DSP0PinMap["PCOUT[26]"] = -1;
    DSP0PinMap["PCOUT[25]"] = -1;
    DSP0PinMap["PCOUT[24]"] = -1;
    DSP0PinMap["PCOUT[23]"] = -1;
    DSP0PinMap["PCOUT[22]"] = -1;
    DSP0PinMap["PCOUT[21]"] = -1;
    DSP0PinMap["PCOUT[20]"] = -1;
    DSP0PinMap["PCOUT[19]"] = -1;
    DSP0PinMap["PCOUT[18]"] = -1;
    DSP0PinMap["PCOUT[17]"] = -1;
    DSP0PinMap["PCOUT[16]"] = -1;
    DSP0PinMap["PCOUT[15]"] = -1;
    DSP0PinMap["PCOUT[14]"] = -1;
    DSP0PinMap["PCOUT[13]"] = -1;
    DSP0PinMap["PCOUT[12]"] = -1;
    DSP0PinMap["PCOUT[11]"] = -1;
    DSP0PinMap["PCOUT[10]"] = -1;
    DSP0PinMap["PCOUT[9]"] = -1;
    DSP0PinMap["PCOUT[8]"] = -1;
    DSP0PinMap["PCOUT[7]"] = -1;
    DSP0PinMap["PCOUT[6]"] = -1;
    DSP0PinMap["PCOUT[5]"] = -1;
    DSP0PinMap["PCOUT[4]"] = -1;
    DSP0PinMap["PCOUT[3]"] = -1;
    DSP0PinMap["PCOUT[2]"] = -1;
    DSP0PinMap["PCOUT[1]"] = -1;
    DSP0PinMap["PCOUT[0]"] = -1;
    DSP0PinMap["XOROUT[7]"] = 2;
    DSP0PinMap["XOROUT[6]"] = 1;
    DSP0PinMap["XOROUT[5]"] = 1;
    DSP0PinMap["XOROUT[4]"] = 1;
    DSP0PinMap["XOROUT[3]"] = 1;
    DSP0PinMap["XOROUT[2]"] = 0;
    DSP0PinMap["XOROUT[1]"] = 0;
    DSP0PinMap["XOROUT[0]"] = 0;

    // DSP1
    DSP1PinMap["CARRYCASCIN"] = -1;
    DSP1PinMap["CARRYIN"] = 2;
    DSP1PinMap["CEA1"] = 4;
    DSP1PinMap["CEA2"] = 4;
    DSP1PinMap["CEAD"] = 3;
    DSP1PinMap["CEALUMODE"] = 4;
    DSP1PinMap["CEB1"] = 3;
    DSP1PinMap["CEB2"] = 4;
    DSP1PinMap["CEC"] = 2;
    DSP1PinMap["CECARRYIN"] = 3;
    DSP1PinMap["CECTRL"] = 4;
    DSP1PinMap["CED"] = 3;
    DSP1PinMap["CEINMODE"] = 4;
    DSP1PinMap["CEM"] = 3;
    DSP1PinMap["CEP"] = 2;
    DSP1PinMap["CLK"] = 3;
    DSP1PinMap["MULTSIGNIN"] = -1;
    DSP1PinMap["RSTA"] = 4;
    DSP1PinMap["RSTALLCARRYIN"] = 4;
    DSP1PinMap["RSTALUMODE"] = 4;
    DSP1PinMap["RSTB"] = 3;
    DSP1PinMap["RSTC"] = 2;
    DSP1PinMap["RSTCTRL"] = 4;
    DSP1PinMap["RSTD"] = 3;
    DSP1PinMap["RSTINMODE"] = 4;
    DSP1PinMap["RSTM"] = 3;
    DSP1PinMap["RSTP"] = 2;
    DSP1PinMap["A[29]"] = 4;
    DSP1PinMap["A[28]"] = 4;
    DSP1PinMap["A[27]"] = 4;
    DSP1PinMap["A[26]"] = 4;
    DSP1PinMap["A[25]"] = 4;
    DSP1PinMap["A[24]"] = 4;
    DSP1PinMap["A[23]"] = 4;
    DSP1PinMap["A[22]"] = 4;
    DSP1PinMap["A[21]"] = 3;
    DSP1PinMap["A[20]"] = 3;
    DSP1PinMap["A[19]"] = 3;
    DSP1PinMap["A[18]"] = 3;
    DSP1PinMap["A[17]"] = 3;
    DSP1PinMap["A[16]"] = 3;
    DSP1PinMap["A[15]"] = 3;
    DSP1PinMap["A[14]"] = 3;
    DSP1PinMap["A[13]"] = 2;
    DSP1PinMap["A[12]"] = 2;
    DSP1PinMap["A[11]"] = 2;
    DSP1PinMap["A[10]"] = 2;
    DSP1PinMap["A[9]"] = 2;
    DSP1PinMap["A[8]"] = 2;
    DSP1PinMap["A[7]"] = 2;
    DSP1PinMap["A[6]"] = 2;
    DSP1PinMap["A[5]"] = 1;
    DSP1PinMap["A[4]"] = 1;
    DSP1PinMap["A[3]"] = 1;
    DSP1PinMap["A[2]"] = 1;
    DSP1PinMap["A[1]"] = 1;
    DSP1PinMap["A[0]"] = 1;
    DSP1PinMap["ACIN[29]"] = -1;
    DSP1PinMap["ACIN[28]"] = -1;
    DSP1PinMap["ACIN[27]"] = -1;
    DSP1PinMap["ACIN[26]"] = -1;
    DSP1PinMap["ACIN[25]"] = -1;
    DSP1PinMap["ACIN[24]"] = -1;
    DSP1PinMap["ACIN[23]"] = -1;
    DSP1PinMap["ACIN[22]"] = -1;
    DSP1PinMap["ACIN[21]"] = -1;
    DSP1PinMap["ACIN[20]"] = -1;
    DSP1PinMap["ACIN[19]"] = -1;
    DSP1PinMap["ACIN[18]"] = -1;
    DSP1PinMap["ACIN[17]"] = -1;
    DSP1PinMap["ACIN[16]"] = -1;
    DSP1PinMap["ACIN[15]"] = -1;
    DSP1PinMap["ACIN[14]"] = -1;
    DSP1PinMap["ACIN[13]"] = -1;
    DSP1PinMap["ACIN[12]"] = -1;
    DSP1PinMap["ACIN[11]"] = -1;
    DSP1PinMap["ACIN[10]"] = -1;
    DSP1PinMap["ACIN[9]"] = -1;
    DSP1PinMap["ACIN[8]"] = -1;
    DSP1PinMap["ACIN[7]"] = -1;
    DSP1PinMap["ACIN[6]"] = -1;
    DSP1PinMap["ACIN[5]"] = -1;
    DSP1PinMap["ACIN[4]"] = -1;
    DSP1PinMap["ACIN[3]"] = -1;
    DSP1PinMap["ACIN[2]"] = -1;
    DSP1PinMap["ACIN[1]"] = -1;
    DSP1PinMap["ACIN[0]"] = -1;
    DSP1PinMap["B[17]"] = 4;
    DSP1PinMap["B[16]"] = 4;
    DSP1PinMap["B[15]"] = 4;
    DSP1PinMap["B[14]"] = 4;
    DSP1PinMap["B[13]"] = 4;
    DSP1PinMap["B[12]"] = 4;
    DSP1PinMap["B[11]"] = 3;
    DSP1PinMap["B[10]"] = 3;
    DSP1PinMap["B[9]"] = 3;
    DSP1PinMap["B[8]"] = 3;
    DSP1PinMap["B[7]"] = 3;
    DSP1PinMap["B[6]"] = 3;
    DSP1PinMap["B[5]"] = 3;
    DSP1PinMap["B[4]"] = 3;
    DSP1PinMap["B[3]"] = 2;
    DSP1PinMap["B[2]"] = 2;
    DSP1PinMap["B[1]"] = 2;
    DSP1PinMap["B[0]"] = 2;
    DSP1PinMap["BCIN[17]"] = -1;
    DSP1PinMap["BCIN[16]"] = -1;
    DSP1PinMap["BCIN[15]"] = -1;
    DSP1PinMap["BCIN[14]"] = -1;
    DSP1PinMap["BCIN[13]"] = -1;
    DSP1PinMap["BCIN[12]"] = -1;
    DSP1PinMap["BCIN[11]"] = -1;
    DSP1PinMap["BCIN[10]"] = -1;
    DSP1PinMap["BCIN[9]"] = -1;
    DSP1PinMap["BCIN[8]"] = -1;
    DSP1PinMap["BCIN[7]"] = -1;
    DSP1PinMap["BCIN[6]"] = -1;
    DSP1PinMap["BCIN[5]"] = -1;
    DSP1PinMap["BCIN[4]"] = -1;
    DSP1PinMap["BCIN[3]"] = -1;
    DSP1PinMap["BCIN[2]"] = -1;
    DSP1PinMap["BCIN[1]"] = -1;
    DSP1PinMap["BCIN[0]"] = -1;
    DSP1PinMap["D[26]"] = 4;
    DSP1PinMap["D[25]"] = 4;
    DSP1PinMap["D[24]"] = 4;
    DSP1PinMap["D[23]"] = 4;
    DSP1PinMap["D[22]"] = 4;
    DSP1PinMap["D[21]"] = 4;
    DSP1PinMap["D[20]"] = 4;
    DSP1PinMap["D[19]"] = 4;
    DSP1PinMap["D[18]"] = 3;
    DSP1PinMap["D[17]"] = 3;
    DSP1PinMap["D[16]"] = 3;
    DSP1PinMap["D[15]"] = 3;
    DSP1PinMap["D[14]"] = 3;
    DSP1PinMap["D[13]"] = 3;
    DSP1PinMap["D[12]"] = 3;
    DSP1PinMap["D[11]"] = 3;
    DSP1PinMap["D[10]"] = 2;
    DSP1PinMap["D[9]"] = 2;
    DSP1PinMap["D[8]"] = 2;
    DSP1PinMap["D[7]"] = 2;
    DSP1PinMap["D[6]"] = 2;
    DSP1PinMap["D[5]"] = 2;
    DSP1PinMap["D[4]"] = 2;
    DSP1PinMap["D[3]"] = 2;
    DSP1PinMap["D[2]"] = 1;
    DSP1PinMap["D[1]"] = 1;
    DSP1PinMap["D[0]"] = 1;
    DSP1PinMap["CARRYINSEL[2]"] = 4;
    DSP1PinMap["CARRYINSEL[1]"] = 4;
    DSP1PinMap["CARRYINSEL[0]"] = 4;
    DSP1PinMap["ALUMODE[3]"] = 4;
    DSP1PinMap["ALUMODE[2]"] = 4;
    DSP1PinMap["ALUMODE[1]"] = 4;
    DSP1PinMap["ALUMODE[0]"] = 3;
    DSP1PinMap["C[47]"] = 4;
    DSP1PinMap["C[46]"] = 4;
    DSP1PinMap["C[45]"] = 3;
    DSP1PinMap["C[44]"] = 3;
    DSP1PinMap["C[43]"] = 3;
    DSP1PinMap["C[42]"] = 3;
    DSP1PinMap["C[41]"] = 2;
    DSP1PinMap["C[40]"] = 2;
    DSP1PinMap["C[39]"] = 4;
    DSP1PinMap["C[38]"] = 4;
    DSP1PinMap["C[37]"] = 4;
    DSP1PinMap["C[36]"] = 4;
    DSP1PinMap["C[35]"] = 4;
    DSP1PinMap["C[34]"] = 4;
    DSP1PinMap["C[33]"] = 4;
    DSP1PinMap["C[32]"] = 4;
    DSP1PinMap["C[31]"] = 3;
    DSP1PinMap["C[30]"] = 3;
    DSP1PinMap["C[29]"] = 3;
    DSP1PinMap["C[28]"] = 3;
    DSP1PinMap["C[27]"] = 3;
    DSP1PinMap["C[26]"] = 3;
    DSP1PinMap["C[25]"] = 3;
    DSP1PinMap["C[24]"] = 3;
    DSP1PinMap["C[23]"] = 2;
    DSP1PinMap["C[22]"] = 2;
    DSP1PinMap["C[21]"] = 2;
    DSP1PinMap["C[20]"] = 2;
    DSP1PinMap["C[19]"] = 2;
    DSP1PinMap["C[18]"] = 2;
    DSP1PinMap["C[17]"] = 2;
    DSP1PinMap["C[16]"] = 2;
    DSP1PinMap["C[15]"] = 1;
    DSP1PinMap["C[14]"] = 1;
    DSP1PinMap["C[13]"] = 1;
    DSP1PinMap["C[12]"] = 1;
    DSP1PinMap["C[11]"] = 1;
    DSP1PinMap["C[10]"] = 1;
    DSP1PinMap["C[9]"] = 1;
    DSP1PinMap["C[8]"] = 1;
    DSP1PinMap["C[7]"] = 0;
    DSP1PinMap["C[6]"] = 0;
    DSP1PinMap["C[5]"] = 0;
    DSP1PinMap["C[4]"] = 0;
    DSP1PinMap["C[3]"] = 0;
    DSP1PinMap["C[2]"] = 0;
    DSP1PinMap["C[1]"] = 0;
    DSP1PinMap["C[0]"] = 0;
    DSP1PinMap["PCIN[47]"] = -1;
    DSP1PinMap["PCIN[46]"] = -1;
    DSP1PinMap["PCIN[45]"] = -1;
    DSP1PinMap["PCIN[44]"] = -1;
    DSP1PinMap["PCIN[43]"] = -1;
    DSP1PinMap["PCIN[42]"] = -1;
    DSP1PinMap["PCIN[41]"] = -1;
    DSP1PinMap["PCIN[40]"] = -1;
    DSP1PinMap["PCIN[39]"] = -1;
    DSP1PinMap["PCIN[38]"] = -1;
    DSP1PinMap["PCIN[37]"] = -1;
    DSP1PinMap["PCIN[36]"] = -1;
    DSP1PinMap["PCIN[35]"] = -1;
    DSP1PinMap["PCIN[34]"] = -1;
    DSP1PinMap["PCIN[33]"] = -1;
    DSP1PinMap["PCIN[32]"] = -1;
    DSP1PinMap["PCIN[31]"] = -1;
    DSP1PinMap["PCIN[30]"] = -1;
    DSP1PinMap["PCIN[29]"] = -1;
    DSP1PinMap["PCIN[28]"] = -1;
    DSP1PinMap["PCIN[27]"] = -1;
    DSP1PinMap["PCIN[26]"] = -1;
    DSP1PinMap["PCIN[25]"] = -1;
    DSP1PinMap["PCIN[24]"] = -1;
    DSP1PinMap["PCIN[23]"] = -1;
    DSP1PinMap["PCIN[22]"] = -1;
    DSP1PinMap["PCIN[21]"] = -1;
    DSP1PinMap["PCIN[20]"] = -1;
    DSP1PinMap["PCIN[19]"] = -1;
    DSP1PinMap["PCIN[18]"] = -1;
    DSP1PinMap["PCIN[17]"] = -1;
    DSP1PinMap["PCIN[16]"] = -1;
    DSP1PinMap["PCIN[15]"] = -1;
    DSP1PinMap["PCIN[14]"] = -1;
    DSP1PinMap["PCIN[13]"] = -1;
    DSP1PinMap["PCIN[12]"] = -1;
    DSP1PinMap["PCIN[11]"] = -1;
    DSP1PinMap["PCIN[10]"] = -1;
    DSP1PinMap["PCIN[9]"] = -1;
    DSP1PinMap["PCIN[8]"] = -1;
    DSP1PinMap["PCIN[7]"] = -1;
    DSP1PinMap["PCIN[6]"] = -1;
    DSP1PinMap["PCIN[5]"] = -1;
    DSP1PinMap["PCIN[4]"] = -1;
    DSP1PinMap["PCIN[3]"] = -1;
    DSP1PinMap["PCIN[2]"] = -1;
    DSP1PinMap["PCIN[1]"] = -1;
    DSP1PinMap["PCIN[0]"] = -1;
    DSP1PinMap["INMODE[4]"] = 4;
    DSP1PinMap["INMODE[3]"] = 4;
    DSP1PinMap["INMODE[2]"] = 4;
    DSP1PinMap["INMODE[1]"] = 4;
    DSP1PinMap["INMODE[0]"] = 4;
    DSP1PinMap["OPMODE[8]"] = 4;
    DSP1PinMap["OPMODE[7]"] = 4;
    DSP1PinMap["OPMODE[6]"] = 4;
    DSP1PinMap["OPMODE[5]"] = 3;
    DSP1PinMap["OPMODE[4]"] = 3;
    DSP1PinMap["OPMODE[3]"] = 3;
    DSP1PinMap["OPMODE[2]"] = 3;
    DSP1PinMap["OPMODE[1]"] = 2;
    DSP1PinMap["OPMODE[0]"] = 2;
    DSP1PinMap["CARRYCASCOUT"] = -1;
    DSP1PinMap["MULTSIGNOUT"] = -1;
    DSP1PinMap["OVERFLOW"] = 3;
    DSP1PinMap["PATTERNBDETECT"] = 2;
    DSP1PinMap["PATTERNDETECT"] = 4;
    DSP1PinMap["UNDERFLOW"] = 3;
    DSP1PinMap["BCOUT[17]"] = -1;
    DSP1PinMap["BCOUT[16]"] = -1;
    DSP1PinMap["BCOUT[15]"] = -1;
    DSP1PinMap["BCOUT[14]"] = -1;
    DSP1PinMap["BCOUT[13]"] = -1;
    DSP1PinMap["BCOUT[12]"] = -1;
    DSP1PinMap["BCOUT[11]"] = -1;
    DSP1PinMap["BCOUT[10]"] = -1;
    DSP1PinMap["BCOUT[9]"] = -1;
    DSP1PinMap["BCOUT[8]"] = -1;
    DSP1PinMap["BCOUT[7]"] = -1;
    DSP1PinMap["BCOUT[6]"] = -1;
    DSP1PinMap["BCOUT[5]"] = -1;
    DSP1PinMap["BCOUT[4]"] = -1;
    DSP1PinMap["BCOUT[3]"] = -1;
    DSP1PinMap["BCOUT[2]"] = -1;
    DSP1PinMap["BCOUT[1]"] = -1;
    DSP1PinMap["BCOUT[0]"] = -1;
    DSP1PinMap["ACOUT[29]"] = -1;
    DSP1PinMap["ACOUT[28]"] = -1;
    DSP1PinMap["ACOUT[27]"] = -1;
    DSP1PinMap["ACOUT[26]"] = -1;
    DSP1PinMap["ACOUT[25]"] = -1;
    DSP1PinMap["ACOUT[24]"] = -1;
    DSP1PinMap["ACOUT[23]"] = -1;
    DSP1PinMap["ACOUT[22]"] = -1;
    DSP1PinMap["ACOUT[21]"] = -1;
    DSP1PinMap["ACOUT[20]"] = -1;
    DSP1PinMap["ACOUT[19]"] = -1;
    DSP1PinMap["ACOUT[18]"] = -1;
    DSP1PinMap["ACOUT[17]"] = -1;
    DSP1PinMap["ACOUT[16]"] = -1;
    DSP1PinMap["ACOUT[15]"] = -1;
    DSP1PinMap["ACOUT[14]"] = -1;
    DSP1PinMap["ACOUT[13]"] = -1;
    DSP1PinMap["ACOUT[12]"] = -1;
    DSP1PinMap["ACOUT[11]"] = -1;
    DSP1PinMap["ACOUT[10]"] = -1;
    DSP1PinMap["ACOUT[9]"] = -1;
    DSP1PinMap["ACOUT[8]"] = -1;
    DSP1PinMap["ACOUT[7]"] = -1;
    DSP1PinMap["ACOUT[6]"] = -1;
    DSP1PinMap["ACOUT[5]"] = -1;
    DSP1PinMap["ACOUT[4]"] = -1;
    DSP1PinMap["ACOUT[3]"] = -1;
    DSP1PinMap["ACOUT[2]"] = -1;
    DSP1PinMap["ACOUT[1]"] = -1;
    DSP1PinMap["ACOUT[0]"] = -1;
    DSP1PinMap["CARRYOUT[3]"] = 2;
    DSP1PinMap["CARRYOUT[2]"] = 4;
    DSP1PinMap["CARRYOUT[1]"] = 2;
    DSP1PinMap["CARRYOUT[0]"] = 1;
    DSP1PinMap["P[47]"] = 4;
    DSP1PinMap["P[46]"] = 4;
    DSP1PinMap["P[45]"] = 3;
    DSP1PinMap["P[44]"] = 3;
    DSP1PinMap["P[43]"] = 3;
    DSP1PinMap["P[42]"] = 3;
    DSP1PinMap["P[41]"] = 2;
    DSP1PinMap["P[40]"] = 2;
    DSP1PinMap["P[39]"] = 4;
    DSP1PinMap["P[38]"] = 4;
    DSP1PinMap["P[37]"] = 4;
    DSP1PinMap["P[36]"] = 4;
    DSP1PinMap["P[35]"] = 4;
    DSP1PinMap["P[34]"] = 4;
    DSP1PinMap["P[33]"] = 4;
    DSP1PinMap["P[32]"] = 4;
    DSP1PinMap["P[31]"] = 3;
    DSP1PinMap["P[30]"] = 3;
    DSP1PinMap["P[29]"] = 3;
    DSP1PinMap["P[28]"] = 3;
    DSP1PinMap["P[27]"] = 3;
    DSP1PinMap["P[26]"] = 3;
    DSP1PinMap["P[25]"] = 3;
    DSP1PinMap["P[24]"] = 3;
    DSP1PinMap["P[23]"] = 2;
    DSP1PinMap["P[22]"] = 2;
    DSP1PinMap["P[21]"] = 2;
    DSP1PinMap["P[20]"] = 2;
    DSP1PinMap["P[19]"] = 2;
    DSP1PinMap["P[18]"] = 2;
    DSP1PinMap["P[17]"] = 2;
    DSP1PinMap["P[16]"] = 2;
    DSP1PinMap["P[15]"] = 1;
    DSP1PinMap["P[14]"] = 1;
    DSP1PinMap["P[13]"] = 1;
    DSP1PinMap["P[12]"] = 1;
    DSP1PinMap["P[11]"] = 1;
    DSP1PinMap["P[10]"] = 1;
    DSP1PinMap["P[9]"] = 1;
    DSP1PinMap["P[8]"] = 1;
    DSP1PinMap["P[7]"] = 0;
    DSP1PinMap["P[6]"] = 0;
    DSP1PinMap["P[5]"] = 0;
    DSP1PinMap["P[4]"] = 0;
    DSP1PinMap["P[3]"] = 0;
    DSP1PinMap["P[2]"] = 0;
    DSP1PinMap["P[1]"] = 0;
    DSP1PinMap["P[0]"] = 0;
    DSP1PinMap["PCOUT[47]"] = -1;
    DSP1PinMap["PCOUT[46]"] = -1;
    DSP1PinMap["PCOUT[45]"] = -1;
    DSP1PinMap["PCOUT[44]"] = -1;
    DSP1PinMap["PCOUT[43]"] = -1;
    DSP1PinMap["PCOUT[42]"] = -1;
    DSP1PinMap["PCOUT[41]"] = -1;
    DSP1PinMap["PCOUT[40]"] = -1;
    DSP1PinMap["PCOUT[39]"] = -1;
    DSP1PinMap["PCOUT[38]"] = -1;
    DSP1PinMap["PCOUT[37]"] = -1;
    DSP1PinMap["PCOUT[36]"] = -1;
    DSP1PinMap["PCOUT[35]"] = -1;
    DSP1PinMap["PCOUT[34]"] = -1;
    DSP1PinMap["PCOUT[33]"] = -1;
    DSP1PinMap["PCOUT[32]"] = -1;
    DSP1PinMap["PCOUT[31]"] = -1;
    DSP1PinMap["PCOUT[30]"] = -1;
    DSP1PinMap["PCOUT[29]"] = -1;
    DSP1PinMap["PCOUT[28]"] = -1;
    DSP1PinMap["PCOUT[27]"] = -1;
    DSP1PinMap["PCOUT[26]"] = -1;
    DSP1PinMap["PCOUT[25]"] = -1;
    DSP1PinMap["PCOUT[24]"] = -1;
    DSP1PinMap["PCOUT[23]"] = -1;
    DSP1PinMap["PCOUT[22]"] = -1;
    DSP1PinMap["PCOUT[21]"] = -1;
    DSP1PinMap["PCOUT[20]"] = -1;
    DSP1PinMap["PCOUT[19]"] = -1;
    DSP1PinMap["PCOUT[18]"] = -1;
    DSP1PinMap["PCOUT[17]"] = -1;
    DSP1PinMap["PCOUT[16]"] = -1;
    DSP1PinMap["PCOUT[15]"] = -1;
    DSP1PinMap["PCOUT[14]"] = -1;
    DSP1PinMap["PCOUT[13]"] = -1;
    DSP1PinMap["PCOUT[12]"] = -1;
    DSP1PinMap["PCOUT[11]"] = -1;
    DSP1PinMap["PCOUT[10]"] = -1;
    DSP1PinMap["PCOUT[9]"] = -1;
    DSP1PinMap["PCOUT[8]"] = -1;
    DSP1PinMap["PCOUT[7]"] = -1;
    DSP1PinMap["PCOUT[6]"] = -1;
    DSP1PinMap["PCOUT[5]"] = -1;
    DSP1PinMap["PCOUT[4]"] = -1;
    DSP1PinMap["PCOUT[3]"] = -1;
    DSP1PinMap["PCOUT[2]"] = -1;
    DSP1PinMap["PCOUT[1]"] = -1;
    DSP1PinMap["PCOUT[0]"] = -1;
    DSP1PinMap["XOROUT[7]"] = 4;
    DSP1PinMap["XOROUT[6]"] = 4;
    DSP1PinMap["XOROUT[5]"] = 4;
    DSP1PinMap["XOROUT[4]"] = 3;
    DSP1PinMap["XOROUT[3]"] = 3;
    DSP1PinMap["XOROUT[2]"] = 3;
    DSP1PinMap["XOROUT[1]"] = 3;
    DSP1PinMap["XOROUT[0]"] = 2;

    // BRAM
    BRAMPinMap["CASOUTDBITERR"] = -1;
    BRAMPinMap["CASOUTSBITERR"] = -1;
    BRAMPinMap["DBITERR"] = 2;
    BRAMPinMap["SBITERR"] = 2;
    BRAMPinMap["CASDOUTA[31]"] = -1;
    BRAMPinMap["CASDOUTA[30]"] = -1;
    BRAMPinMap["CASDOUTA[29]"] = -1;
    BRAMPinMap["CASDOUTA[28]"] = -1;
    BRAMPinMap["CASDOUTA[27]"] = -1;
    BRAMPinMap["CASDOUTA[26]"] = -1;
    BRAMPinMap["CASDOUTA[25]"] = -1;
    BRAMPinMap["CASDOUTA[24]"] = -1;
    BRAMPinMap["CASDOUTA[23]"] = -1;
    BRAMPinMap["CASDOUTA[22]"] = -1;
    BRAMPinMap["CASDOUTA[21]"] = -1;
    BRAMPinMap["CASDOUTA[20]"] = -1;
    BRAMPinMap["CASDOUTA[19]"] = -1;
    BRAMPinMap["CASDOUTA[18]"] = -1;
    BRAMPinMap["CASDOUTA[17]"] = -1;
    BRAMPinMap["CASDOUTA[16]"] = -1;
    BRAMPinMap["CASDOUTA[15]"] = -1;
    BRAMPinMap["CASDOUTA[14]"] = -1;
    BRAMPinMap["CASDOUTA[13]"] = -1;
    BRAMPinMap["CASDOUTA[12]"] = -1;
    BRAMPinMap["CASDOUTA[11]"] = -1;
    BRAMPinMap["CASDOUTA[10]"] = -1;
    BRAMPinMap["CASDOUTA[9]"] = -1;
    BRAMPinMap["CASDOUTA[8]"] = -1;
    BRAMPinMap["CASDOUTA[7]"] = -1;
    BRAMPinMap["CASDOUTA[6]"] = -1;
    BRAMPinMap["CASDOUTA[5]"] = -1;
    BRAMPinMap["CASDOUTA[4]"] = -1;
    BRAMPinMap["CASDOUTA[3]"] = -1;
    BRAMPinMap["CASDOUTA[2]"] = -1;
    BRAMPinMap["CASDOUTA[1]"] = -1;
    BRAMPinMap["CASDOUTA[0]"] = -1;
    BRAMPinMap["CASDOUTB[31]"] = -1;
    BRAMPinMap["CASDOUTB[30]"] = -1;
    BRAMPinMap["CASDOUTB[29]"] = -1;
    BRAMPinMap["CASDOUTB[28]"] = -1;
    BRAMPinMap["CASDOUTB[27]"] = -1;
    BRAMPinMap["CASDOUTB[26]"] = -1;
    BRAMPinMap["CASDOUTB[25]"] = -1;
    BRAMPinMap["CASDOUTB[24]"] = -1;
    BRAMPinMap["CASDOUTB[23]"] = -1;
    BRAMPinMap["CASDOUTB[22]"] = -1;
    BRAMPinMap["CASDOUTB[21]"] = -1;
    BRAMPinMap["CASDOUTB[20]"] = -1;
    BRAMPinMap["CASDOUTB[19]"] = -1;
    BRAMPinMap["CASDOUTB[18]"] = -1;
    BRAMPinMap["CASDOUTB[17]"] = -1;
    BRAMPinMap["CASDOUTB[16]"] = -1;
    BRAMPinMap["CASDOUTB[15]"] = -1;
    BRAMPinMap["CASDOUTB[14]"] = -1;
    BRAMPinMap["CASDOUTB[13]"] = -1;
    BRAMPinMap["CASDOUTB[12]"] = -1;
    BRAMPinMap["CASDOUTB[11]"] = -1;
    BRAMPinMap["CASDOUTB[10]"] = -1;
    BRAMPinMap["CASDOUTB[9]"] = -1;
    BRAMPinMap["CASDOUTB[8]"] = -1;
    BRAMPinMap["CASDOUTB[7]"] = -1;
    BRAMPinMap["CASDOUTB[6]"] = -1;
    BRAMPinMap["CASDOUTB[5]"] = -1;
    BRAMPinMap["CASDOUTB[4]"] = -1;
    BRAMPinMap["CASDOUTB[3]"] = -1;
    BRAMPinMap["CASDOUTB[2]"] = -1;
    BRAMPinMap["CASDOUTB[1]"] = -1;
    BRAMPinMap["CASDOUTB[0]"] = -1;
    BRAMPinMap["DOUTADOUT[31]"] = 4;
    BRAMPinMap["DOUTADOUT[30]"] = 4;
    BRAMPinMap["DOUTADOUT[29]"] = 4;
    BRAMPinMap["DOUTADOUT[28]"] = 4;
    BRAMPinMap["DOUTADOUT[27]"] = 3;
    BRAMPinMap["DOUTADOUT[26]"] = 3;
    BRAMPinMap["DOUTADOUT[25]"] = 3;
    BRAMPinMap["DOUTADOUT[24]"] = 2;
    BRAMPinMap["DOUTADOUT[23]"] = 4;
    BRAMPinMap["DOUTADOUT[22]"] = 4;
    BRAMPinMap["DOUTADOUT[21]"] = 4;
    BRAMPinMap["DOUTADOUT[20]"] = 4;
    BRAMPinMap["DOUTADOUT[19]"] = 3;
    BRAMPinMap["DOUTADOUT[18]"] = 3;
    BRAMPinMap["DOUTADOUT[17]"] = 3;
    BRAMPinMap["DOUTADOUT[16]"] = 2;
    BRAMPinMap["DOUTADOUT[15]"] = 2;
    BRAMPinMap["DOUTADOUT[14]"] = 1;
    BRAMPinMap["DOUTADOUT[13]"] = 1;
    BRAMPinMap["DOUTADOUT[12]"] = 1;
    BRAMPinMap["DOUTADOUT[11]"] = 0;
    BRAMPinMap["DOUTADOUT[10]"] = 0;
    BRAMPinMap["DOUTADOUT[9]"] = 0;
    BRAMPinMap["DOUTADOUT[8]"] = 0;
    BRAMPinMap["DOUTADOUT[7]"] = 2;
    BRAMPinMap["DOUTADOUT[6]"] = 1;
    BRAMPinMap["DOUTADOUT[5]"] = 1;
    BRAMPinMap["DOUTADOUT[4]"] = 1;
    BRAMPinMap["DOUTADOUT[3]"] = 0;
    BRAMPinMap["DOUTADOUT[2]"] = 0;
    BRAMPinMap["DOUTADOUT[1]"] = 0;
    BRAMPinMap["DOUTADOUT[0]"] = 0;
    BRAMPinMap["DOUTBDOUT[31]"] = 4;
    BRAMPinMap["DOUTBDOUT[30]"] = 4;
    BRAMPinMap["DOUTBDOUT[29]"] = 4;
    BRAMPinMap["DOUTBDOUT[28]"] = 4;
    BRAMPinMap["DOUTBDOUT[27]"] = 3;
    BRAMPinMap["DOUTBDOUT[26]"] = 3;
    BRAMPinMap["DOUTBDOUT[25]"] = 3;
    BRAMPinMap["DOUTBDOUT[24]"] = 2;
    BRAMPinMap["DOUTBDOUT[23]"] = 4;
    BRAMPinMap["DOUTBDOUT[22]"] = 4;
    BRAMPinMap["DOUTBDOUT[21]"] = 4;
    BRAMPinMap["DOUTBDOUT[20]"] = 4;
    BRAMPinMap["DOUTBDOUT[19]"] = 3;
    BRAMPinMap["DOUTBDOUT[18]"] = 3;
    BRAMPinMap["DOUTBDOUT[17]"] = 3;
    BRAMPinMap["DOUTBDOUT[16]"] = 2;
    BRAMPinMap["DOUTBDOUT[15]"] = 2;
    BRAMPinMap["DOUTBDOUT[14]"] = 1;
    BRAMPinMap["DOUTBDOUT[13]"] = 1;
    BRAMPinMap["DOUTBDOUT[12]"] = 1;
    BRAMPinMap["DOUTBDOUT[11]"] = 0;
    BRAMPinMap["DOUTBDOUT[10]"] = 0;
    BRAMPinMap["DOUTBDOUT[9]"] = 0;
    BRAMPinMap["DOUTBDOUT[8]"] = 0;
    BRAMPinMap["DOUTBDOUT[7]"] = 2;
    BRAMPinMap["DOUTBDOUT[6]"] = 1;
    BRAMPinMap["DOUTBDOUT[5]"] = 1;
    BRAMPinMap["DOUTBDOUT[4]"] = 1;
    BRAMPinMap["DOUTBDOUT[3]"] = 0;
    BRAMPinMap["DOUTBDOUT[2]"] = 0;
    BRAMPinMap["DOUTBDOUT[1]"] = 0;
    BRAMPinMap["DOUTBDOUT[0]"] = 0;
    BRAMPinMap["CASDOUTPA[3]"] = -1;
    BRAMPinMap["CASDOUTPA[2]"] = -1;
    BRAMPinMap["CASDOUTPA[1]"] = -1;
    BRAMPinMap["CASDOUTPA[0]"] = -1;
    BRAMPinMap["CASDOUTPB[3]"] = -1;
    BRAMPinMap["CASDOUTPB[2]"] = -1;
    BRAMPinMap["CASDOUTPB[1]"] = -1;
    BRAMPinMap["CASDOUTPB[0]"] = -1;
    BRAMPinMap["DOUTPADOUTP[3]"] = 3;
    BRAMPinMap["DOUTPADOUTP[2]"] = 3;
    BRAMPinMap["DOUTPADOUTP[1]"] = 1;
    BRAMPinMap["DOUTPADOUTP[0]"] = 1;
    BRAMPinMap["DOUTPBDOUTP[3]"] = 3;
    BRAMPinMap["DOUTPBDOUTP[2]"] = 3;
    BRAMPinMap["DOUTPBDOUTP[1]"] = 1;
    BRAMPinMap["DOUTPBDOUTP[0]"] = 1;
    BRAMPinMap["ECCPARITY[7]"] = 4;
    BRAMPinMap["ECCPARITY[6]"] = 4;
    BRAMPinMap["ECCPARITY[5]"] = 4;
    BRAMPinMap["ECCPARITY[4]"] = 4;
    BRAMPinMap["ECCPARITY[3]"] = 4;
    BRAMPinMap["ECCPARITY[2]"] = 4;
    BRAMPinMap["ECCPARITY[1]"] = 4;
    BRAMPinMap["ECCPARITY[0]"] = 4;
    BRAMPinMap["RDADDRECC[8]"] = 0;
    BRAMPinMap["RDADDRECC[7]"] = 0;
    BRAMPinMap["RDADDRECC[6]"] = 0;
    BRAMPinMap["RDADDRECC[5]"] = 0;
    BRAMPinMap["RDADDRECC[4]"] = 0;
    BRAMPinMap["RDADDRECC[3]"] = 0;
    BRAMPinMap["RDADDRECC[2]"] = 0;
    BRAMPinMap["RDADDRECC[1]"] = 0;
    BRAMPinMap["RDADDRECC[0]"] = 0;
    BRAMPinMap["ADDRENA"] = 2;
    BRAMPinMap["ADDRENB"] = 1;
    BRAMPinMap["CASDIMUXA"] = 2;
    BRAMPinMap["CASDIMUXB"] = 2;
    BRAMPinMap["CASDOMUXA"] = 2;
    BRAMPinMap["CASDOMUXB"] = 2;
    BRAMPinMap["CASDOMUXEN_A"] = 3;
    BRAMPinMap["CASDOMUXEN_B"] = 2;
    BRAMPinMap["CASINDBITERR"] = -1;
    BRAMPinMap["CASINSBITERR"] = -1;
    BRAMPinMap["CASOREGIMUXA"] = 3;
    BRAMPinMap["CASOREGIMUXB"] = 0;
    BRAMPinMap["CASOREGIMUXEN_A"] = 0;
    BRAMPinMap["CASOREGIMUXEN_B"] = 1;
    BRAMPinMap["CLKARDCLK"] = 3;  // E1
    BRAMPinMap["CLKBWRCLK"] = 4;  // E2
    BRAMPinMap["ECCPIPECE"] = 2;
    BRAMPinMap["ENARDEN"] = 2;
    BRAMPinMap["ENBWREN"] = 1;
    BRAMPinMap["INJECTDBITERR"] = 2;
    BRAMPinMap["INJECTSBITERR"] = 2;
    BRAMPinMap["REGCEAREGCE"] = 2;
    BRAMPinMap["REGCEB"] = 1;
    BRAMPinMap["RSTRAMARSTRAM"] = 3;
    BRAMPinMap["RSTRAMB"] = 1;
    BRAMPinMap["RSTREGARSTREG"] = 3;
    BRAMPinMap["RSTREGB"] = 2;
    BRAMPinMap["SLEEP"] = 4;
    BRAMPinMap["ADDRARDADDR[14]"] = 4;
    BRAMPinMap["ADDRARDADDR[13]"] = 4;
    BRAMPinMap["ADDRARDADDR[12]"] = 4;
    BRAMPinMap["ADDRARDADDR[11]"] = 3;
    BRAMPinMap["ADDRARDADDR[10]"] = 3;
    BRAMPinMap["ADDRARDADDR[9]"] = 3;
    BRAMPinMap["ADDRARDADDR[8]"] = 3;
    BRAMPinMap["ADDRARDADDR[7]"] = 2;
    BRAMPinMap["ADDRARDADDR[6]"] = 2;
    BRAMPinMap["ADDRARDADDR[5]"] = 1;
    BRAMPinMap["ADDRARDADDR[4]"] = 1;
    BRAMPinMap["ADDRARDADDR[3]"] = 1;
    BRAMPinMap["ADDRARDADDR[2]"] = 1;
    BRAMPinMap["ADDRARDADDR[1]"] = 0;
    BRAMPinMap["ADDRARDADDR[0]"] = 0;
    BRAMPinMap["ADDRBWRADDR[14]"] = 4;
    BRAMPinMap["ADDRBWRADDR[13]"] = 4;
    BRAMPinMap["ADDRBWRADDR[12]"] = 4;
    BRAMPinMap["ADDRBWRADDR[11]"] = 3;
    BRAMPinMap["ADDRBWRADDR[10]"] = 3;
    BRAMPinMap["ADDRBWRADDR[9]"] = 3;
    BRAMPinMap["ADDRBWRADDR[8]"] = 3;
    BRAMPinMap["ADDRBWRADDR[7]"] = 2;
    BRAMPinMap["ADDRBWRADDR[6]"] = 2;
    BRAMPinMap["ADDRBWRADDR[5]"] = 1;
    BRAMPinMap["ADDRBWRADDR[4]"] = 1;
    BRAMPinMap["ADDRBWRADDR[3]"] = 1;
    BRAMPinMap["ADDRBWRADDR[2]"] = 1;
    BRAMPinMap["ADDRBWRADDR[1]"] = 0;
    BRAMPinMap["ADDRBWRADDR[0]"] = 0;
    BRAMPinMap["CASDINA[31]"] = -1;
    BRAMPinMap["CASDINA[30]"] = -1;
    BRAMPinMap["CASDINA[29]"] = -1;
    BRAMPinMap["CASDINA[28]"] = -1;
    BRAMPinMap["CASDINA[27]"] = -1;
    BRAMPinMap["CASDINA[26]"] = -1;
    BRAMPinMap["CASDINA[25]"] = -1;
    BRAMPinMap["CASDINA[24]"] = -1;
    BRAMPinMap["CASDINA[23]"] = -1;
    BRAMPinMap["CASDINA[22]"] = -1;
    BRAMPinMap["CASDINA[21]"] = -1;
    BRAMPinMap["CASDINA[20]"] = -1;
    BRAMPinMap["CASDINA[19]"] = -1;
    BRAMPinMap["CASDINA[18]"] = -1;
    BRAMPinMap["CASDINA[17]"] = -1;
    BRAMPinMap["CASDINA[16]"] = -1;
    BRAMPinMap["CASDINA[15]"] = -1;
    BRAMPinMap["CASDINA[14]"] = -1;
    BRAMPinMap["CASDINA[13]"] = -1;
    BRAMPinMap["CASDINA[12]"] = -1;
    BRAMPinMap["CASDINA[11]"] = -1;
    BRAMPinMap["CASDINA[10]"] = -1;
    BRAMPinMap["CASDINA[9]"] = -1;
    BRAMPinMap["CASDINA[8]"] = -1;
    BRAMPinMap["CASDINA[7]"] = -1;
    BRAMPinMap["CASDINA[6]"] = -1;
    BRAMPinMap["CASDINA[5]"] = -1;
    BRAMPinMap["CASDINA[4]"] = -1;
    BRAMPinMap["CASDINA[3]"] = -1;
    BRAMPinMap["CASDINA[2]"] = -1;
    BRAMPinMap["CASDINA[1]"] = -1;
    BRAMPinMap["CASDINA[0]"] = -1;
    BRAMPinMap["CASDINB[31]"] = -1;
    BRAMPinMap["CASDINB[30]"] = -1;
    BRAMPinMap["CASDINB[29]"] = -1;
    BRAMPinMap["CASDINB[28]"] = -1;
    BRAMPinMap["CASDINB[27]"] = -1;
    BRAMPinMap["CASDINB[26]"] = -1;
    BRAMPinMap["CASDINB[25]"] = -1;
    BRAMPinMap["CASDINB[24]"] = -1;
    BRAMPinMap["CASDINB[23]"] = -1;
    BRAMPinMap["CASDINB[22]"] = -1;
    BRAMPinMap["CASDINB[21]"] = -1;
    BRAMPinMap["CASDINB[20]"] = -1;
    BRAMPinMap["CASDINB[19]"] = -1;
    BRAMPinMap["CASDINB[18]"] = -1;
    BRAMPinMap["CASDINB[17]"] = -1;
    BRAMPinMap["CASDINB[16]"] = -1;
    BRAMPinMap["CASDINB[15]"] = -1;
    BRAMPinMap["CASDINB[14]"] = -1;
    BRAMPinMap["CASDINB[13]"] = -1;
    BRAMPinMap["CASDINB[12]"] = -1;
    BRAMPinMap["CASDINB[11]"] = -1;
    BRAMPinMap["CASDINB[10]"] = -1;
    BRAMPinMap["CASDINB[9]"] = -1;
    BRAMPinMap["CASDINB[8]"] = -1;
    BRAMPinMap["CASDINB[7]"] = -1;
    BRAMPinMap["CASDINB[6]"] = -1;
    BRAMPinMap["CASDINB[5]"] = -1;
    BRAMPinMap["CASDINB[4]"] = -1;
    BRAMPinMap["CASDINB[3]"] = -1;
    BRAMPinMap["CASDINB[2]"] = -1;
    BRAMPinMap["CASDINB[1]"] = -1;
    BRAMPinMap["CASDINB[0]"] = -1;
    BRAMPinMap["DINADIN[31]"] = 4;
    BRAMPinMap["DINADIN[30]"] = 4;
    BRAMPinMap["DINADIN[29]"] = 4;
    BRAMPinMap["DINADIN[28]"] = 4;
    BRAMPinMap["DINADIN[27]"] = 3;
    BRAMPinMap["DINADIN[26]"] = 3;
    BRAMPinMap["DINADIN[25]"] = 3;
    BRAMPinMap["DINADIN[24]"] = 2;
    BRAMPinMap["DINADIN[23]"] = 4;
    BRAMPinMap["DINADIN[22]"] = 4;
    BRAMPinMap["DINADIN[21]"] = 4;
    BRAMPinMap["DINADIN[20]"] = 4;
    BRAMPinMap["DINADIN[19]"] = 3;
    BRAMPinMap["DINADIN[18]"] = 3;
    BRAMPinMap["DINADIN[17]"] = 3;
    BRAMPinMap["DINADIN[16]"] = 2;
    BRAMPinMap["DINADIN[15]"] = 2;
    BRAMPinMap["DINADIN[14]"] = 1;
    BRAMPinMap["DINADIN[13]"] = 1;
    BRAMPinMap["DINADIN[12]"] = 1;
    BRAMPinMap["DINADIN[11]"] = 0;
    BRAMPinMap["DINADIN[10]"] = 0;
    BRAMPinMap["DINADIN[9]"] = 0;
    BRAMPinMap["DINADIN[8]"] = 0;
    BRAMPinMap["DINADIN[7]"] = 2;
    BRAMPinMap["DINADIN[6]"] = 1;
    BRAMPinMap["DINADIN[5]"] = 1;
    BRAMPinMap["DINADIN[4]"] = 1;
    BRAMPinMap["DINADIN[3]"] = 0;
    BRAMPinMap["DINADIN[2]"] = 0;
    BRAMPinMap["DINADIN[1]"] = 0;
    BRAMPinMap["DINADIN[0]"] = 0;
    BRAMPinMap["DINBDIN[31]"] = 4;
    BRAMPinMap["DINBDIN[30]"] = 4;
    BRAMPinMap["DINBDIN[29]"] = 4;
    BRAMPinMap["DINBDIN[28]"] = 4;
    BRAMPinMap["DINBDIN[27]"] = 3;
    BRAMPinMap["DINBDIN[26]"] = 3;
    BRAMPinMap["DINBDIN[25]"] = 3;
    BRAMPinMap["DINBDIN[24]"] = 2;
    BRAMPinMap["DINBDIN[23]"] = 4;
    BRAMPinMap["DINBDIN[22]"] = 4;
    BRAMPinMap["DINBDIN[21]"] = 4;
    BRAMPinMap["DINBDIN[20]"] = 4;
    BRAMPinMap["DINBDIN[19]"] = 3;
    BRAMPinMap["DINBDIN[18]"] = 3;
    BRAMPinMap["DINBDIN[17]"] = 3;
    BRAMPinMap["DINBDIN[16]"] = 2;
    BRAMPinMap["DINBDIN[15]"] = 2;
    BRAMPinMap["DINBDIN[14]"] = 1;
    BRAMPinMap["DINBDIN[13]"] = 1;
    BRAMPinMap["DINBDIN[12]"] = 1;
    BRAMPinMap["DINBDIN[11]"] = 0;
    BRAMPinMap["DINBDIN[10]"] = 0;
    BRAMPinMap["DINBDIN[9]"] = 0;
    BRAMPinMap["DINBDIN[8]"] = 0;
    BRAMPinMap["DINBDIN[7]"] = 2;
    BRAMPinMap["DINBDIN[6]"] = 1;
    BRAMPinMap["DINBDIN[5]"] = 1;
    BRAMPinMap["DINBDIN[4]"] = 1;
    BRAMPinMap["DINBDIN[3]"] = 0;
    BRAMPinMap["DINBDIN[2]"] = 0;
    BRAMPinMap["DINBDIN[1]"] = 0;
    BRAMPinMap["DINBDIN[0]"] = 0;
    BRAMPinMap["CASDINPA[3]"] = -1;
    BRAMPinMap["CASDINPA[2]"] = -1;
    BRAMPinMap["CASDINPA[1]"] = -1;
    BRAMPinMap["CASDINPA[0]"] = -1;
    BRAMPinMap["CASDINPB[3]"] = -1;
    BRAMPinMap["CASDINPB[2]"] = -1;
    BRAMPinMap["CASDINPB[1]"] = -1;
    BRAMPinMap["CASDINPB[0]"] = -1;
    BRAMPinMap["DINPADINP[3]"] = 3;
    BRAMPinMap["DINPADINP[2]"] = 3;
    BRAMPinMap["DINPADINP[1]"] = 1;
    BRAMPinMap["DINPADINP[0]"] = 1;
    BRAMPinMap["DINPBDINP[3]"] = 3;
    BRAMPinMap["DINPBDINP[2]"] = 3;
    BRAMPinMap["DINPBDINP[1]"] = 1;
    BRAMPinMap["DINPBDINP[0]"] = 1;
    BRAMPinMap["WEA[3]"] = 2;
    BRAMPinMap["WEA[2]"] = 2;
    BRAMPinMap["WEA[1]"] = 2;
    BRAMPinMap["WEA[0]"] = 2;
    BRAMPinMap["WEBWE[7]"] = 2;
    BRAMPinMap["WEBWE[6]"] = 2;
    BRAMPinMap["WEBWE[5]"] = 2;
    BRAMPinMap["WEBWE[4]"] = 2;
    BRAMPinMap["WEBWE[3]"] = 2;
    BRAMPinMap["WEBWE[2]"] = 2;
    BRAMPinMap["WEBWE[1]"] = 2;
    BRAMPinMap["WEBWE[0]"] = 2;

    pinSwitchBoxMap.resize(10);
    pinSwitchBoxMap[PinRuleSlice].resize(1, 0);
    pinSwitchBoxMap[PinRuleDSP0].resize(DSP0PinMap.size(), 0);
    pinSwitchBoxMap[PinRuleDSP1].resize(DSP1PinMap.size(), 0);
    pinSwitchBoxMap[PinRuleBRAM].resize(BRAMPinMap.size(), 0);
    pinSwitchBoxMap[PinRuleInput].resize(50, 0);
    pinSwitchBoxMap[PinRuleOutput].resize(50, 0);
    pinSwitchBoxMap[PinRuleInputS].resize(50, 0);
    pinSwitchBoxMap[PinRuleOutputS].resize(50, 0);

    Master *dsp = getMaster(Master::DSP48E2);
    for (int i = 0; i < (int)dsp->pins.size(); i++) {
        auto p0i = DSP0PinMap.find(dsp->pins[i]->name);
        if (p0i == DSP0PinMap.end()) {
            printlog(LOG_ERROR, "pin not found on DSP0: %s", dsp->pins[i]->name.c_str());
        } else {
            pinSwitchBoxMap[PinRuleDSP0][i] = p0i->second;
        }
        auto p1i = DSP1PinMap.find(dsp->pins[i]->name);
        if (p1i == DSP0PinMap.end()) {
            printlog(LOG_ERROR, "pin not found on DSP1: %s", dsp->pins[i]->name.c_str());
        } else {
            pinSwitchBoxMap[PinRuleDSP1][i] = p1i->second;
        }
    }

    Master *bram = getMaster(Master::RAMB36E2);
    for (int i = 0; i < (int)bram->pins.size(); i++) {
        auto bi = BRAMPinMap.find(bram->pins[i]->name);
        if (bi == BRAMPinMap.end()) {
            printlog(LOG_ERROR, "pin not found on BRAM: %s", bram->pins[i]->name.c_str());
        } else {
            pinSwitchBoxMap[PinRuleBRAM][i] = bi->second;
        }
    }

    pinSwitchBoxMap[PinRuleInput][0] = 22;
    pinSwitchBoxMap[PinRuleInput][1] = 7;
    pinSwitchBoxMap[PinRuleInput][2] = 0;
    pinSwitchBoxMap[PinRuleInput][3] = 1;
    pinSwitchBoxMap[PinRuleInput][4] = 2;
    pinSwitchBoxMap[PinRuleInput][5] = 3;
    pinSwitchBoxMap[PinRuleInput][6] = 4;
    pinSwitchBoxMap[PinRuleInput][7] = 5;
    pinSwitchBoxMap[PinRuleInput][8] = 8;
    pinSwitchBoxMap[PinRuleInput][9] = 9;
    pinSwitchBoxMap[PinRuleInput][10] = 10;
    pinSwitchBoxMap[PinRuleInput][11] = 11;
    pinSwitchBoxMap[PinRuleInput][12] = 12;
    pinSwitchBoxMap[PinRuleInput][13] = 12;
    pinSwitchBoxMap[PinRuleInput][14] = 15;
    pinSwitchBoxMap[PinRuleInput][15] = 16;
    pinSwitchBoxMap[PinRuleInput][16] = 17;
    pinSwitchBoxMap[PinRuleInput][17] = 18;
    pinSwitchBoxMap[PinRuleInput][18] = 19;
    pinSwitchBoxMap[PinRuleInput][19] = 20;
    pinSwitchBoxMap[PinRuleInput][20] = 23;
    pinSwitchBoxMap[PinRuleInput][21] = 24;
    pinSwitchBoxMap[PinRuleInput][22] = 24;
    pinSwitchBoxMap[PinRuleInput][23] = 26;
    pinSwitchBoxMap[PinRuleInput][24] = 27;
    pinSwitchBoxMap[PinRuleInput][25] = 27;

    pinSwitchBoxMap[PinRuleInput][26] = 15;
    pinSwitchBoxMap[PinRuleInput][27] = 15;
    pinSwitchBoxMap[PinRuleInput][28] = 15;
    pinSwitchBoxMap[PinRuleInput][29] = 15;
    pinSwitchBoxMap[PinRuleInput][30] = 15;
    pinSwitchBoxMap[PinRuleInput][31] = 15;
    pinSwitchBoxMap[PinRuleInput][32] = 15;
    pinSwitchBoxMap[PinRuleInput][33] = 15;
    pinSwitchBoxMap[PinRuleInput][34] = 15;
    pinSwitchBoxMap[PinRuleInput][35] = 15;
    pinSwitchBoxMap[PinRuleInput][36] = 15;
    pinSwitchBoxMap[PinRuleInput][37] = 15;
    pinSwitchBoxMap[PinRuleInput][38] = 15;
    pinSwitchBoxMap[PinRuleInput][39] = 15;
    pinSwitchBoxMap[PinRuleInput][40] = 15;
    pinSwitchBoxMap[PinRuleInput][41] = 15;
    pinSwitchBoxMap[PinRuleInput][42] = 15;
    pinSwitchBoxMap[PinRuleInput][43] = 15;
    pinSwitchBoxMap[PinRuleInput][44] = 15;
    pinSwitchBoxMap[PinRuleInput][45] = 15;
    pinSwitchBoxMap[PinRuleInput][46] = 15;
    pinSwitchBoxMap[PinRuleInput][47] = 15;
    pinSwitchBoxMap[PinRuleInput][48] = 15;
    pinSwitchBoxMap[PinRuleInput][49] = 15;

    pinSwitchBoxMap[PinRuleOutput][0] = 22;
    pinSwitchBoxMap[PinRuleOutput][1] = 7;
    pinSwitchBoxMap[PinRuleOutput][2] = 1;
    pinSwitchBoxMap[PinRuleOutput][3] = 2;
    pinSwitchBoxMap[PinRuleOutput][4] = 3;
    pinSwitchBoxMap[PinRuleOutput][5] = 4;
    pinSwitchBoxMap[PinRuleOutput][6] = 5;
    pinSwitchBoxMap[PinRuleOutput][7] = 6;
    pinSwitchBoxMap[PinRuleOutput][8] = 8;
    pinSwitchBoxMap[PinRuleOutput][9] = 9;
    pinSwitchBoxMap[PinRuleOutput][10] = 9;
    pinSwitchBoxMap[PinRuleOutput][11] = 12;
    pinSwitchBoxMap[PinRuleOutput][12] = 13;
    pinSwitchBoxMap[PinRuleOutput][13] = 14;
    pinSwitchBoxMap[PinRuleOutput][14] = 16;
    pinSwitchBoxMap[PinRuleOutput][15] = 17;
    pinSwitchBoxMap[PinRuleOutput][16] = 18;
    pinSwitchBoxMap[PinRuleOutput][17] = 19;
    pinSwitchBoxMap[PinRuleOutput][18] = 20;
    pinSwitchBoxMap[PinRuleOutput][19] = 21;
    pinSwitchBoxMap[PinRuleOutput][20] = 23;
    pinSwitchBoxMap[PinRuleOutput][21] = 24;
    pinSwitchBoxMap[PinRuleOutput][22] = 25;
    pinSwitchBoxMap[PinRuleOutput][23] = 27;
    pinSwitchBoxMap[PinRuleOutput][24] = 28;
    pinSwitchBoxMap[PinRuleOutput][25] = 29;

    pinSwitchBoxMap[PinRuleOutput][26] = 15;
    pinSwitchBoxMap[PinRuleOutput][27] = 15;
    pinSwitchBoxMap[PinRuleOutput][28] = 15;
    pinSwitchBoxMap[PinRuleOutput][29] = 15;
    pinSwitchBoxMap[PinRuleOutput][30] = 15;
    pinSwitchBoxMap[PinRuleOutput][31] = 15;
    pinSwitchBoxMap[PinRuleOutput][32] = 15;
    pinSwitchBoxMap[PinRuleOutput][33] = 15;
    pinSwitchBoxMap[PinRuleOutput][34] = 15;
    pinSwitchBoxMap[PinRuleOutput][35] = 15;
    pinSwitchBoxMap[PinRuleOutput][36] = 15;
    pinSwitchBoxMap[PinRuleOutput][37] = 15;
    pinSwitchBoxMap[PinRuleOutput][38] = 15;
    pinSwitchBoxMap[PinRuleOutput][39] = 15;
    pinSwitchBoxMap[PinRuleOutput][40] = 15;
    pinSwitchBoxMap[PinRuleOutput][41] = 15;
    pinSwitchBoxMap[PinRuleOutput][42] = 15;
    pinSwitchBoxMap[PinRuleOutput][43] = 15;
    pinSwitchBoxMap[PinRuleOutput][44] = 15;
    pinSwitchBoxMap[PinRuleOutput][45] = 15;
    pinSwitchBoxMap[PinRuleOutput][46] = 15;
    pinSwitchBoxMap[PinRuleOutput][47] = 15;
    pinSwitchBoxMap[PinRuleOutput][48] = 15;
    pinSwitchBoxMap[PinRuleOutput][49] = 15;

    pinSwitchBoxMap[PinRuleInputS][0] = 7;
    pinSwitchBoxMap[PinRuleInputS][1] = 22;
    pinSwitchBoxMap[PinRuleInputS][2] = 1;
    pinSwitchBoxMap[PinRuleInputS][3] = 0;
    pinSwitchBoxMap[PinRuleInputS][4] = 1;
    pinSwitchBoxMap[PinRuleInputS][5] = 0;
    pinSwitchBoxMap[PinRuleInputS][6] = 3;
    pinSwitchBoxMap[PinRuleInputS][7] = 2;
    pinSwitchBoxMap[PinRuleInputS][8] = 3;
    pinSwitchBoxMap[PinRuleInputS][9] = 2;
    pinSwitchBoxMap[PinRuleInputS][10] = 5;
    pinSwitchBoxMap[PinRuleInputS][11] = 4;
    pinSwitchBoxMap[PinRuleInputS][12] = 5;
    pinSwitchBoxMap[PinRuleInputS][13] = 4;
    pinSwitchBoxMap[PinRuleInputS][14] = 9;
    pinSwitchBoxMap[PinRuleInputS][15] = 8;
    pinSwitchBoxMap[PinRuleInputS][16] = 9;
    pinSwitchBoxMap[PinRuleInputS][17] = 8;
    pinSwitchBoxMap[PinRuleInputS][18] = 11;
    pinSwitchBoxMap[PinRuleInputS][19] = 10;
    pinSwitchBoxMap[PinRuleInputS][20] = 11;
    pinSwitchBoxMap[PinRuleInputS][21] = 10;
    pinSwitchBoxMap[PinRuleInputS][22] = 12;
    pinSwitchBoxMap[PinRuleInputS][23] = 12;
    pinSwitchBoxMap[PinRuleInputS][24] = 12;
    pinSwitchBoxMap[PinRuleInputS][25] = 12;
    pinSwitchBoxMap[PinRuleInputS][26] = 16;
    pinSwitchBoxMap[PinRuleInputS][27] = 15;
    pinSwitchBoxMap[PinRuleInputS][28] = 16;
    pinSwitchBoxMap[PinRuleInputS][29] = 15;
    pinSwitchBoxMap[PinRuleInputS][30] = 18;
    pinSwitchBoxMap[PinRuleInputS][31] = 17;
    pinSwitchBoxMap[PinRuleInputS][32] = 18;
    pinSwitchBoxMap[PinRuleInputS][33] = 17;
    pinSwitchBoxMap[PinRuleInputS][34] = 20;
    pinSwitchBoxMap[PinRuleInputS][35] = 19;
    pinSwitchBoxMap[PinRuleInputS][36] = 20;
    pinSwitchBoxMap[PinRuleInputS][37] = 19;
    pinSwitchBoxMap[PinRuleInputS][38] = 24;
    pinSwitchBoxMap[PinRuleInputS][39] = 23;
    pinSwitchBoxMap[PinRuleInputS][40] = 24;
    pinSwitchBoxMap[PinRuleInputS][41] = 23;
    pinSwitchBoxMap[PinRuleInputS][42] = 26;
    pinSwitchBoxMap[PinRuleInputS][43] = 24;
    pinSwitchBoxMap[PinRuleInputS][44] = 26;
    pinSwitchBoxMap[PinRuleInputS][45] = 24;
    pinSwitchBoxMap[PinRuleInputS][46] = 27;
    pinSwitchBoxMap[PinRuleInputS][47] = 27;
    pinSwitchBoxMap[PinRuleInputS][48] = 27;
    pinSwitchBoxMap[PinRuleInputS][49] = 27;

    pinSwitchBoxMap[PinRuleOutputS][0] = 7;
    pinSwitchBoxMap[PinRuleOutputS][1] = 22;
    pinSwitchBoxMap[PinRuleOutputS][2] = 2;
    pinSwitchBoxMap[PinRuleOutputS][3] = 1;
    pinSwitchBoxMap[PinRuleOutputS][4] = 2;
    pinSwitchBoxMap[PinRuleOutputS][5] = 1;
    pinSwitchBoxMap[PinRuleOutputS][6] = 4;
    pinSwitchBoxMap[PinRuleOutputS][7] = 3;
    pinSwitchBoxMap[PinRuleOutputS][8] = 4;
    pinSwitchBoxMap[PinRuleOutputS][9] = 3;
    pinSwitchBoxMap[PinRuleOutputS][10] = 6;
    pinSwitchBoxMap[PinRuleOutputS][11] = 5;
    pinSwitchBoxMap[PinRuleOutputS][12] = 6;
    pinSwitchBoxMap[PinRuleOutputS][13] = 5;
    pinSwitchBoxMap[PinRuleOutputS][14] = 9;
    pinSwitchBoxMap[PinRuleOutputS][15] = 8;
    pinSwitchBoxMap[PinRuleOutputS][16] = 9;
    pinSwitchBoxMap[PinRuleOutputS][17] = 8;
    pinSwitchBoxMap[PinRuleOutputS][18] = 12;
    pinSwitchBoxMap[PinRuleOutputS][19] = 9;
    pinSwitchBoxMap[PinRuleOutputS][20] = 12;
    pinSwitchBoxMap[PinRuleOutputS][21] = 9;
    pinSwitchBoxMap[PinRuleOutputS][22] = 14;
    pinSwitchBoxMap[PinRuleOutputS][23] = 13;
    pinSwitchBoxMap[PinRuleOutputS][24] = 14;
    pinSwitchBoxMap[PinRuleOutputS][25] = 13;
    pinSwitchBoxMap[PinRuleOutputS][26] = 17;
    pinSwitchBoxMap[PinRuleOutputS][27] = 16;
    pinSwitchBoxMap[PinRuleOutputS][28] = 17;
    pinSwitchBoxMap[PinRuleOutputS][29] = 16;
    pinSwitchBoxMap[PinRuleOutputS][30] = 19;
    pinSwitchBoxMap[PinRuleOutputS][31] = 18;
    pinSwitchBoxMap[PinRuleOutputS][32] = 19;
    pinSwitchBoxMap[PinRuleOutputS][33] = 18;
    pinSwitchBoxMap[PinRuleOutputS][34] = 21;
    pinSwitchBoxMap[PinRuleOutputS][35] = 20;
    pinSwitchBoxMap[PinRuleOutputS][36] = 21;
    pinSwitchBoxMap[PinRuleOutputS][37] = 20;
    pinSwitchBoxMap[PinRuleOutputS][38] = 24;
    pinSwitchBoxMap[PinRuleOutputS][39] = 23;
    pinSwitchBoxMap[PinRuleOutputS][40] = 24;
    pinSwitchBoxMap[PinRuleOutputS][41] = 23;
    pinSwitchBoxMap[PinRuleOutputS][42] = 27;
    pinSwitchBoxMap[PinRuleOutputS][43] = 25;
    pinSwitchBoxMap[PinRuleOutputS][44] = 27;
    pinSwitchBoxMap[PinRuleOutputS][45] = 25;
    pinSwitchBoxMap[PinRuleOutputS][46] = 29;
    pinSwitchBoxMap[PinRuleOutputS][47] = 28;
    pinSwitchBoxMap[PinRuleOutputS][48] = 29;
    pinSwitchBoxMap[PinRuleOutputS][49] = 28;
}
